package com.baor.service.impl;

import com.baor.dao.SyslogDao;
import com.baor.domain.SyslogVo;
import com.baor.service.SyslogService;
import com.baor.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class SyslogServiceImpl implements SyslogService {

    @Autowired
    private SyslogDao syslogDao;


    @Override
    public AjaxResult<?> logList(Map<String,Object> map) {
        if ( map.get("pageIndex") == null || "".equals(map.get("pageIndex")) )
            map.put("pageIndex",1);
        if ( map.get("pageSize") == null || "".equals(map.get("pageSize")) )
            map.put("pageSize",10);
        map.put("pageIndex", Integer.valueOf(map.get("pageSize").toString()) * (Integer.valueOf(map.get("pageIndex").toString()) - 1));
        map.put("pageSize",Integer.valueOf(map.get("pageSize").toString()));
        List<SyslogVo> list = syslogDao.list(map);
        Integer pageCount = syslogDao.pageCount(map);
        Map<String,Object> res = new HashMap<>();
        res.put("pageCount",pageCount);
        res.put("syslogList",list);
        return AjaxResult.success(res);
    }

}
